home *** CD-ROM | disk | FTP | other *** search
/ Quick PC 61 / Quick PC 61.iso / I386 / WMS.CAB / WMSSession.asp < prev    next >
Encoding:
Text File  |  2003-02-21  |  11.3 KB  |  340 lines

  1. ∩╗┐<%@ Language=VBScript CODEPAGE=65001 %>
  2. <!--#include file="include/wmsConstants.inc"-->
  3. <!--#include file="include/wmsLocStrings.inc"-->
  4. <!--#include file="include/wmsServerHash.inc"-->
  5. <!--#include file="include/wmsconnect.inc"-->
  6. <!--#include file="include/wmsCommon.inc"-->
  7. <!--#include file="include/wmsHeader.inc"-->
  8. <!--#include file="include/wmsError.inc"-->
  9. <%
  10. '+-------------------------------------------------------------------------
  11. '
  12. '  Microsoft Windows Media
  13. '  Copyright (C) Microsoft Corporation. All rights reserved.
  14. '
  15. '  File:        WMSSession.asp
  16. '
  17. '  Contents:    used in hidden frame to keep session alive
  18. '  
  19. '--------------------------------------------------------------------------
  20.  
  21. if( ( FALSE = Session( "Initialized" ) ) or ( 0 < Len( Request.QueryString( "logoff" ) ) ) ) then
  22.     HandleLogoff
  23. end if
  24.  
  25. '////////////////////////////////////////////////////////////////
  26. Sub HandleLogoff()
  27.     on error resume next
  28.     
  29.     Dim objSession
  30.     Set objSession = Session( "CurSession" )
  31.     objSession.Logoff
  32.     
  33.     Session.Timeout = 0
  34.     Session.Abandon
  35.     
  36.     %><html><head></head><body onload="window.parent.location.replace( '/wmslogoff.asp?terminate=1&close=1' );"></body></html><%
  37.  
  38.     Response.Flush
  39.     Response.End
  40. End Sub
  41.  
  42. ' Keeps the session alive-- important!
  43. Dim strUrl
  44. strUrl = ""
  45.  
  46. if( 0 < Len( qs( "server" ) ) ) then
  47.     strUrl = Request.ServerVariables("url") & "?server=" & qs( "server" ) & "&keepaliveseed=" & Second( Now )
  48. else
  49.     strUrl = Request.ServerVariables("url") & "?keepaliveseed=" & Second( Now )
  50. end if
  51.  
  52. if( 0 = Len( qs( "heartbeat" ) ) ) then
  53.     dwHeartbeat = 1
  54. else
  55.     dwHeartbeat = qs( "heartbeat" ) + 1
  56.     if( dwHeartbeat > HEARTBEATS_BETWEEN_OM_PING ) then
  57.         dwHeartbeat = dwHeartbeat mod HEARTBEATS_BETWEEN_OM_PING
  58.     end if
  59. end if
  60.  
  61. WriteHTMLHeader( "Session KeepAlive" )
  62. %>
  63. <meta HTTP-EQUIV="refresh" content="<%= HEARTBEAT_INTERVAL %>;url=<%= strUrl %>&heartbeat=<%= dwHeartbeat %>"/>
  64. <script language="JavaScript" src="include/WMSCommon.js"></script>
  65. <script language="JavaScript">
  66. <!--
  67. /*@cc_on @*/
  68. <% DisableContextMenu %>
  69. window.name="WMSSession";
  70. var g_bLogOffClickHandled = false;
  71. var g_bInitialized = false;
  72. var g_strLastElement = new String("");
  73.  
  74. ///////////////////////////////////////////////////////////////////////
  75. function InformHostWin()
  76. {
  77.     <% jsTRY %>
  78.         var win = null;
  79.         win = window.open( "", "sList", "", true );
  80.         if( win )
  81.         {
  82.             var szWinLocation = new String( "" );
  83.  
  84. /*@if (@_jscript_version >= 1.3)
  85.             try 
  86.             {
  87. @end @*/
  88.             if( win.location )
  89.             {
  90.                 szWinLocation = win.location.toString();
  91.             }
  92. /*@if (@_jscript_version >= 1.3)
  93.             }
  94.             catch( except )
  95.             {
  96.             }
  97. @end @*/
  98.  
  99.             if( ( "about:blank" == szWinLocation ) || ( 0 == szWinLocation.length ) )
  100.             {
  101.                 win.close();
  102.             }
  103.             else
  104.             {
  105.                 win.RecordLocalHostWinName( window.parent.name );
  106.             }
  107.         }
  108.         else
  109.         {
  110.         }
  111.     <% jsCATCH %>
  112. }
  113.  
  114. ///////////////////////////////////////////////////////////////////////
  115. function SetWinName()
  116. {
  117.     <% jsTRY %>
  118.     var win = null; <%
  119.  
  120.     Dim strWinName
  121.     strWinName = g_strQueryStringServer
  122.     if( 0 >= Len( strWinName ) )then
  123.         if( Session("ShowServerList") ) then
  124.             strWinName = "sList"
  125.         end if
  126.     end if
  127. %>
  128.         if( window.parent && window.parent.top )
  129.         {
  130.             if( window.parent.top.name != "<%= strWinName %>" )
  131.             {
  132.                 win = window.parent.top;
  133.             }
  134.         }
  135.         else
  136.         {
  137.             if( window.parent )
  138.             {
  139.                 if( window.parent.name != "<%= strWinName %>" )
  140.                 {
  141.                     win = window.parent;
  142.                 }
  143.             }
  144.             else
  145.             {
  146.                 win = window;
  147.             }
  148.         }
  149.         if( win )
  150.         {
  151.             win.name = "<%= strWinName %>";
  152.         }
  153.     <% jsCATCH %>
  154. }
  155. SetWinName();
  156. <%
  157. '
  158. ' Ensure the session didn't expire.  If it did, then refresh the 
  159. '  server list so that the links will work properly.
  160. '
  161. if ( 0 = Len( qs( "server" ) ) ) and ( FALSE = Session( "Initialized" ) ) then
  162. %>
  163. ///////////////////////////////////////////////////////////////////////
  164. function Init()
  165. {
  166.     <% jsTRY %>
  167.         if( window.parent && window.parent.top )
  168.         {
  169.             window.parent.top.location = "/default.asp";
  170.         }
  171.         else
  172.         {
  173.             if( window.parent )
  174.             {
  175.                 window.parent.location = "/default.asp";
  176.             }
  177.         }
  178.     <% jsCATCH %>
  179. }
  180. Init();
  181. <% end if %>
  182.  
  183. ///////////////////////////////////////////////////////////////////////
  184. function HandleKeyUp()
  185. {
  186.     Logoff();
  187. }
  188.  
  189. ///////////////////////////////////////////////////////////////////////
  190. function Logoff()
  191. {
  192.     <% jsTRY %>
  193.         if( g_bLogOffClickHandled )
  194.         {
  195.             return;
  196.         }
  197.         
  198.         if( ! window.confirm( "<% if( TRUE = Session( "ShowServerList" ) ) then Response.Write( RemoveDangerousCharacters( L_LOGOFFSLCONF_TEXT ) ) else Response.Write( RemoveDangerousCharacters( L_LOGOFFCONF_TEXT ) ) end if %>" ) )
  199.         {
  200.             return;
  201.         }
  202.         
  203.         g_bLogOffClickHandled = true;
  204.         TellSessionFrameToAbandon();
  205.  
  206.         var winServerList = null;
  207.         var szFeatures = "";
  208.         winServerList = window.open( "", "sList", szFeatures, true );        
  209.         if( winServerList )
  210.         {
  211.             var szwinLoc = new String( winServerList.location );
  212.             if( 0 < szwinLoc.length )
  213.             {
  214.                 winServerList.location.replace( document.location.protocol + "//" + document.location.hostname + ":" + document.location.port + "/WMSLogOff.asp?terminate=1" );
  215.             }
  216.         }
  217.         var winHelp = window.open( "", "HELP", szFeatures, true );
  218.         window.focus();
  219.         if( winHelp )
  220.         {
  221.             winHelp.close();
  222.         }
  223.  
  224.         window.focus();
  225.         window.parent.parent.location.replace( document.location.protocol + "//" + document.location.hostname + ":" + document.location.port + "/WMSLogOff.asp?terminate=1&close=1" );
  226.     <% jsCATCH %>
  227. }
  228.  
  229. ///////////////////////////////////////////////////////////////////////
  230. function TellSessionFrameToAbandon()
  231. {
  232.     <% jsTRY %>
  233.         document.location.replace( document.location + "&logoff=true" );
  234.     <% jsCATCH %>
  235. }
  236.  
  237. ///////////////////////////////////////////////////////////////////////
  238. function DoMouseHover( bEntering )
  239. {
  240.     <% jsTRY %>
  241.     if( bEntering )
  242.     {
  243.         logofftext.style.color = "green";
  244.         logofftable.style.background = "#FFFFAA";
  245.     }    
  246.     else
  247.     {
  248.         logofftext.style.color = "white";
  249.         logofftable.style.background = "#6699FF";
  250.     }    
  251.     <% jsCATCH %>
  252. }
  253.  
  254. ///////////////////////////////////////////////////////////////////////
  255. function ShowSecurity()
  256. {
  257.     <% jsTRY %>
  258.         var win;
  259.         var szUrl = new String( "/default.asp?lhwn=<%= Session( "LocalHostWinName" ) %>" );
  260.         var szFeatures = "";
  261.         win = window.open( szUrl, "sList", szFeatures, true );        
  262.         if( win )
  263.         {
  264.             win.focus();
  265.         }
  266.     <% jsCATCH %>
  267. }
  268. -->
  269. </script>
  270. </head>
  271. <body <% if ( 0 < Len( Request.QueryString( "InformHostWin" ) ) ) then %>onload="JavaScript:InformHostWin();"<% end if %> bgcolor="#6699FF" oncontextmenu="JavaScript:event.cancelBubble=true;return false;">
  272. <table height="20" width="100%" cellspacing="1" cellpadding="0" bgcolor="#6699FF">
  273. <tr>
  274.     <td width="100%" align="left" valign="top">
  275.         <a href="JavaScript:HandleKeyUp();">
  276.         <table tabIndex="0" ID="logofftable" cellspacing="0" cellpadding="0" border="1" style="border-collapse:collapse" bgcolor="#6699FF" bordercolor="#6699FF" onMouseEnter="JavaScript:DoMouseHover( true );" onMouseLeave="JavaScript:DoMouseHover( false );" onClick="JavaScript:Logoff();" >
  277.         <tr>
  278.             <td>
  279.                 <table cellspacing="2" cellpadding="0" border="0" ID="Table1" class="logoffbtn">
  280.                 <tr numcols="2">
  281.                     <td align="right" width="24" nowrap style="cursor:<% if ( brMSIE <> Session( "BrowserType" ) ) then %>default<% else %>hand<% end if %>">
  282.                         <span nowrap align="right" valign="absmiddle" style="cursor:<% if ( brMSIE <> Session( "BrowserType" ) ) then %>default<% else %>hand<% end if %>" title="<%= Server.HTMLEncode( L_LOGOFFBTN_TEXT ) %>">
  283.                             <img height="24" width="24" src="img/WMSLogoff_24.gif" border="0" alt="<%= Server.HTMLEncode( L_LOGOFFALT_TEXT ) %>">
  284.                         </span>
  285.                     </td>
  286.                     <td align="right" valign="middle" width="*" nowrap>
  287.                         <div ID="logofftext" valign="absmiddle" align="left" style="color:white;FONT-FAMILY:Tahoma,Arial,Helvetica,sans-serif;FONT-WEIGHT:bold;FONT-SIZE=16;cursor:<% if ( brMSIE <> Session( "BrowserType" ) ) then %>default<% else %>hand<% end if %>" title="<%= Server.HTMLEncode( L_LOGOFFALT_TEXT ) %>" nowrap> <%= SpacesToNonbreak( Server.HTMLEncode( L_LOGOFFBTN_TEXT ) ) %> </div>
  288.                     </td>
  289.                 </tr>
  290.                 </table>
  291.             </td>
  292.         </tr>
  293.         </table>
  294.         </a>
  295.     </td>
  296. <%
  297. if( FALSE and FALSE = g_bSecureConnection ) then
  298. %>
  299.     <td height="24" valign="top" align="left">
  300.         <table cellspacing="0" cellpadding="0" bgcolor="#6699FF" bordercolor="#6699FF" border="1" style="border-width=0" height="24" width="100%" hspace="0" vspace="0">
  301.             <tr valign="middle">
  302.                 <td>
  303.                     <table cellpadding="0" cellspacing="0" border="0">
  304.                     <tr>
  305.                         <td nowrap align="absmiddle">
  306.                             <a href="JavaScript:ShowSecurity();">
  307.                             <img border="0" valign="middle" height="24" width="24" alt="<%= Server.HTMLEncode( L_NONSECUREWARNING_TEXT ) %>" src="img/not_secure_24.gif">
  308.                             </a>
  309.                         </td>
  310.                         <td>
  311.                             <span class="defaultcursor"> </span>
  312.                         </td>
  313.                         <td nowrap valign="middle">
  314.                             <span title="<%= Server.HTMLEncode( L_NONSECUREWARNING_TEXT ) %>" onClick="JavaScript:ShowSecurity();" class="warntext" style="cursor:<% if ( brMSIE <> Session( "BrowserType" ) ) then %>default<% else %>hand<% end if %>" id="nonsecure" valign="middle" href="http://<%= Request.ServerVariables( "HTTP_HOST" ) %>/default.asp" target="sList" border="0">
  315.                                 <% if ( brMSIE <> Session( "BrowserType" ) ) then %><a class="warntext" style="cursor:<% if ( brMSIE <> Session( "BrowserType" ) ) then %>default<% else %>hand<% end if %>" href="JavaScript:ShowSecurity();"><font color="#ff0000"><% end if %><%= Server.HTMLEncode( L_NONSECURE_TEXT ) %><% if( brMSIE <> Session( "BrowserType" ) ) then %></font></a><% end if %>
  316.                             </span>
  317.                         </td>
  318.                     </tr>
  319.                     </table>
  320.                 </td>
  321.             </tr>
  322.         </table>
  323.     </td>
  324. <%
  325. end if %>
  326. </tr>
  327. </table>
  328. <%
  329. if( HEARTBEATS_BETWEEN_OM_PING = dwHeartbeat ) then
  330.     on error resume next
  331.     if( 0 < Len( g_strDecodedServerName ) ) then
  332.         ConnectToNamedServer g_strDecodedServerName, "connect", g_objServer
  333.     end if
  334. end if %>
  335. </body>
  336. </html>
  337. <%
  338. WMSServerHashASPCleanup
  339. WMSConnectASPCleanup
  340. %>